<template>
  <div class="container">
    <el-dialog
      title="题目预览"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose"
    >
      <el-row :gutter="20">
        <el-col :span="6"
          ><div class="grid-content bg-purple">【题型】:{{previewData.questionType}}</div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">【编号】:{{previewData.id}}</div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">【难度】:{{previewData.difficulty}}</div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">【标签】:{{previewData.tags}}</div></el-col
        >
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6"
          ><div class="grid-content bg-purple">【学科】:{{previewData.subjectName}}</div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">【目录】:{{previewData.directoryName}}</div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">【方向】:{{previewData.direction}}</div></el-col
        >
      </el-row>
      <el-divider></el-divider>
      <div class="question">【题干】: <span v-html="previewData.question"></span></div>
      <div></div>
      <div>{{previewData.questionType==='1'?'单选题 选项：(以下选中的选项为正确答案)':previewData.questionType==='2'?'多选题 选项：(以下选中的选项为正确答案)':''}}</div>
       <el-form >
        <el-form-item label="" v-if="previewData.questionType==='1'">
      <el-radio-group

        v-model="radio"
        style="display: flex; flex-flow: column nowrap; align-items: flex-start"
      >
        <el-radio   v-for="item in previewData.options" :key="item.id" :label="item.title" ></el-radio>
      </el-radio-group>
  </el-form-item>

 <el-form-item label="" v-if="previewData.questionType==='2'">
       <el-checkbox-group  v-model="checkList">
    <el-checkbox  v-for="item in previewData.options" :key="item.id" :label="item.title"></el-checkbox>
  </el-checkbox-group>
   </el-form-item>
       </el-form>

      <el-divider></el-divider>
      <div>【参考答案】: <el-button type="danger" @click="isVideo=true">视频答案预览</el-button></div>
       <video v-if="isVideo"  preload="auto" style="width: 400px;height: 300px;margin-top:30px" controls="controls" ></video>
      <el-divider></el-divider>
        <div class="answer"><span>【答案解析】：</span><i v-html="previewData.answer"></i></div>
      <el-divider></el-divider>
        <div>【题目备注】：{{previewData.remarks}}</div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { detail } from '@/api/hmmm/questions.js'
export default {
  data () {
    return {
      isVideo: false,
      radio: 4,
      dialogVisible: false,
      previewData: {}
    }
  },
  methods: {
    handleClose () {
      this.dialogVisible = false
      this.isVideo = false
    },
    async detailData (id) {
      const { data } = await detail({ id })
      console.log(data)
      this.previewData = data
    }
  }
}
</script>

<style scoped lang="less">
.answer{
  position: relative;
  height: 30px;
  i{
    position: absolute;
    top: -13px;
    left: 95px;
    font-style: normal;
  }
}
.question{
  display: flex;
  span{
    margin-top: -13px;
    margin-left: 10px;

  }
}
</style>
